﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;

namespace ВУИ
{
    public partial class ShemaOtt : Form
    {
        Form1 Main;
        int Id;
        public ShemaOtt(Form1 main, int id)
        {
            InitializeComponent();
            Main = main;
            Id = id;
            List<ReportParameter> paramList = new List<ReportParameter>();
            paramList.Add(new ReportParameter("ФИО", Main.lPatient[Main.itnPatietn(id)].This.Surname + " " + Main.lPatient[Main.itnPatietn(id)].This.Name + " " + Main.lPatient[Main.itnPatietn(id)].This.Patronymic));
            paramList.Add(new ReportParameter("Дата", Main.lPatient[Main.itnPatietn(id)].Date_of_birth.ToShortDateString()));
            reportViewer1.LocalReport.SetParameters(paramList);

            List<ReportShema> r = new List<ReportShema>();

            int d = (Main.lPatient[Main.itnPatietn(id)].Statement_date - Main.lPatient[Main.itnPatietn(id)].Date_of_birth).Days;

            foreach (Osmotr e in main.lSdn)
            {
                ReportShema r1 = new ReportShema();
                r1.Врач = e.Врач;

                if ((d<3*30) & ((e.N3) | (((e.Врач == "кардиолог") | (e.Врач == "ЭКГ, ЭХО-КГ")) & (Main.lPatient[Main.itnPatietn(id)].Diagnoz.organ.IndexOf(1) > 0)) | (((e.Врач == "пульмонолог") | (e.Врач == "ЛОР")) & (Main.lPatient[Main.itnPatietn(id)].Diagnoz.organ.IndexOf(2) > 0)) | (((e.Врач == "гепатолог")) & (Main.lPatient[Main.itnPatietn(id)].Diagnoz.organ.IndexOf(3) > 0)) | (((e.Врач == "нефролог")) & (Main.lPatient[Main.itnPatietn(id)].Diagnoz.organ.IndexOf(4) > 0))))
                {
                    r1.N3 = "+";
                }
                else
                {
                    r1.N3 = "";
                }
                if ((d<4*30) & (e.N4))
                {
                    r1.N4 = "+";
                }
                else
                {
                    r1.N4 = "";
                }
                if ((d<5*30) & (e.N5))
                {
                    r1.N5 = "+";
                }
                else
                {
                    r1.N5 = "";
                }
                if ((d<6*30) & ((e.N6) | ((e.Врач == "НСГ") & (Main.lPatient[Main.itnPatietn(id)].Diagnoz.organ.IndexOf(6) > 0)) | ((e.Врач == "кардиолог") & (Main.lPatient[Main.itnPatietn(id)].Diagnoz.organ.IndexOf(1) > 0)) | (((e.Врач == "пульмонолог") | (e.Врач == "ЛОР")) & (Main.lPatient[Main.itnPatietn(id)].Diagnoz.organ.IndexOf(2) > 0)) | (((e.Врач == "нефролог")) & (Main.lPatient[Main.itnPatietn(id)].Diagnoz.organ.IndexOf(4) > 0)) | (((e.Врач == "офтальмолог")) & (Main.lPatient[Main.itnPatietn(id)].Diagnoz.organ.IndexOf(5) > 0))))
                {
                    r1.N6 = "+";
                }
                else
                {
                    r1.N6 = "";
                }
                if ((d<7*30) & (e.N7))
                {
                    r1.N7 = "+";
                }
                else
                {
                    r1.N7 = "";
                }
                if ((d<8*30) & (e.N8))
                {
                    r1.N8 = "+";
                }
                else
                {
                    r1.N8 = "";
                }
                if ((d<9*30) & ((e.N9) | ((e.Врач == "НСГ") & (Main.lPatient[Main.itnPatietn(id)].Diagnoz.organ.IndexOf(6) > 0)) | (((e.Врач == "гепатолог") | (e.Врач == "УЗИ органов ")) & (Main.lPatient[Main.itnPatietn(id)].Diagnoz.organ.IndexOf(3) > 0)) | (( (e.Врач == "УЗИ органов ")) & (Main.lPatient[Main.itnPatietn(id)].Diagnoz.organ.IndexOf(4) > 0))))
                {
                    r1.N9 = "+";
                }
                else
                {
                    r1.N9 = "";
                }
                if ((d<10*30) & (e.N10))
                {
                    r1.N10 = "+";
                }
                else
                {
                    r1.N10 = "";
                }
                if ((d<11*30) & (e.N11))
                {
                    r1.N11 = "+";
                }
                else
                {
                    r1.N11 = "";
                }
                if ((d<12*30) & ((e.N12) | ((e.Врач == "кардиолог") & (Main.lPatient[Main.itnPatietn(id)].Diagnoz.organ.IndexOf(1) > 0)) | (((e.Врач == "пульмонолог")) & (Main.lPatient[Main.itnPatietn(id)].Diagnoz.organ.IndexOf(2) > 0)) | (((e.Врач == "гепатолог")) & (Main.lPatient[Main.itnPatietn(id)].Diagnoz.organ.IndexOf(3) > 0)) | (((e.Врач == "нефролог")) & (Main.lPatient[Main.itnPatietn(id)].Diagnoz.organ.IndexOf(4) > 0)) | (((e.Врач == "офтальмолог")) & (Main.lPatient[Main.itnPatietn(id)].Diagnoz.organ.IndexOf(5) > 0))))
                {
                    r1.N12 = "+";
                }
                else
                {
                    r1.N12 = "";
                }
                if ((d<15*30) & (e.N15))
                {
                    r1.N15 = "+";
                }
                else
                {
                    r1.N15 = "";
                }
                if ((d<18*30) & (e.N18))
                {
                    r1.N18 = "+";
                }
                else
                {
                    r1.N18 = "";
                }
                if ((d<21*30) & (e.N21))
                {
                    r1.N21 = "+";
                }
                else
                {
                    r1.N21 = "";
                }
                if ((d<24*30) & (e.N24))
                {
                    r1.N24 = "+";
                }
                else
                {
                    r1.N24 = "";
                }
                r.Add(r1);
            }
           


            this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet2", r));
           
        }

        private void ShemaOtt_Load(object sender, EventArgs e)
        {

            this.reportViewer1.RefreshReport();
        }

        private void reportViewer1_Load(object sender, EventArgs e)
        {

        }
    }
}
